/**************************************************************************
File:        micromachine.h
Description:

Copyright:   (C) 2001 by ZJ Laczik
Email:       Zsolt.Laczik@eng.ox.ac.uk
****************************************************************************
Change log:
   begin      Fri Mar 16 11:54:32 GMT 2001
   15/2/2012	QT4 update
***************************************************************************/

#ifndef MICROMACHINE_H
#define MICROMACHINE_H

#include <QApplication>
#include <QMainWindow>
#include <QMenuBar>
#include <QMenu>
#include <QStatusBar>
#include <QAction>
#include <QActionGroup>

#include "config.h"
#include "frontpanel.h"
#include "steppertiming.h"
#include "hal.h"
#include "laser.h"
#include "positioner.h"
#include "batchprocessor.h"

class Micromachine : public QMainWindow
{
    Q_OBJECT
public:
    Micromachine(QWidget * parent = 0, Qt::WindowFlags f = (Qt::Window));
    ~Micromachine();
public slots:
    void closeEvent( QCloseEvent* ce );
    void slotFileQuit();
    void slotViewStatusBar();
    void slotPosDspZoom(QAction* a);
    void slotStatusHelpMsg(const QString &text);
private slots:
    void slotFileNew();
    void slotFileOpen();
    bool slotFileSave();
    bool slotFileSaveAs();
    void slotHelpAbout();

    void slotDocumentWasModified();

    void slotStatusActionCallback(QAction* a);
public:
    Hal* mHal;
private:
    void createActions();
    void initMenuBar();
    void initStatusBar();
    void initFrontPanel();
    void initStepperTimingDlg();
    void initConnections();
    void setDefaults();

    void readSettings();
    void writeSettings();
    bool maybeSave();
    void loadFile(const QString &fileName);
    bool saveFile(const QString &fileName);
    void setCurrentFile(const QString &fileName);

    QString strippedName(const QString &fullFileName);
    QString curFile;


    FrontPanel*		mFrontPanel;
    StepperTiming*	mStepperTiming;
    Laser*		mLaser;
    Positioner*		mPositioner;
    BatchProcessor* 	mBatchProc;

    QMenu	*fileMenu;
    QMenu	*editMenu;
    QMenu	*viewMenu;
    QMenu	*settingsMenu;
    QMenu	*helpMenu;

    QAction	*fileNewAct;
    QAction	*fileOpenAct;
    QAction	*fileSaveAct;
    QAction	*fileSaveAsAct;
    QAction	*fileCloseAct;
    QAction	*fileQuitAct;

    QAction	*editUndoAct;
    QAction	*editRedoAct;
    QAction	*editCutAct;
    QAction	*editCopyAct;
    QAction	*editPasteAct;

    QAction	*viewStatusBarAct;
    QAction	*viewPosDspZoom1Act;
    QAction	*viewPosDspZoom10Act;
    QAction	*viewPosDspZoom100Act;
    QAction	*viewPosDspZoom1000Act;
    QActionGroup *viewPosDspZooms;

    QAction	*settingDummyCtrl;
    QAction	*settingIP28Ctrl;
    QAction	*settingZJLPPCtrl;
    QAction	*settingComediUSBDUXCtrl;
    QActionGroup *settingControllers;

    QAction	*settingStepperTiming;
    
    QAction	*settingLaserInterlockDisable;

    QAction	*helpAboutAct;
    QAction	*helpAboutQtAct;

    int		mHeightWithStatus;
    int		mHeight;
};
#endif

